﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<style>
    a.grid_link{text-decoration:underline;}
</style>
<script type="text/javascript">
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        //$('select').bindSelect();
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Product/GetPartsJson",
            height: $(window).height() - 126,
            colModel: [
                {
                    label: '操作', name: '', width: 70, align: 'center', sortable: false, frozen: true, formatter: function (cellvalue, options, rowObject) {
                        return '<a id="" class="grid_link" href="javascript:;" onclick="do_multiquery_calculate(\'' + rowObject.RID + '\',\'' + rowObject.TH + '\')" style="width:45px;">计算</a>';
                    }
                },
                { label: '零件编号', name: 'TH', width: 140, align: 'left', sortable: false, frozen: true },
                { label: '零件名称', name: 'MC', width: 220, align: 'left', sortable: false, frozen: true },
                { label: 'ID', name: 'RID', width: 60, align: 'left', sortable: false, hidden: true },
                { label: '类', name: 'LEI', width: 60, align: 'left', sortable: false },
                { label: '特征', name: 'TX', width: 40, align: 'center', sortable: false },
                { label: '状态', name: 'ZT', width: 40, align: 'center', sortable: false },
                { label: '类别', name: '', width: 80, align: 'center' },
                { label: '装配', name: 'AssembleLine', width: 40, align: 'center', sortable: false },
                { label: '制造路线', name: 'MakeLine', width: 240, align: 'left', sortable: false },
                { label: '版本', name: 'BB', width: 40, align: 'center', sortable: false },
                { label: '版次', name: 'BC', width: 40, align: 'center', sortable: false },
                { label: '技术更改单编号', name: 'LXD', width: 120, align: 'center', sortable: false },
                { label: '参考图号', name: 'CTH', width: 120, align: 'left', sortable: false },
                { label: '图幅', name: 'TF', width: 60, align: 'center', sortable: false },
                { label: '重量', name: 'ZL', width: 60, align: 'center', sortable: false },
                { label: '材料', name: 'CL', width: 80, align: 'center', sortable: false },
                { label: '分级', name: 'JF', width: 80, align: 'center', sortable: false }
            ],
            pager: "#gridPager",
            sortname: 'TH asc',
            viewrecords: true,
            rownumWidth: 40
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $gridList.jqGrid('setFrozenColumns');
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');
        });
    }
    var flag = false;
    function do_multiquery_calculate(id, th) {
        var type = $('input[type=radio].category:checked').val();
        var typeName = type == 'Z' ? "展开" : "回归";
        //alert(type);
        //alert(id + ' ' + th);
        $.modalConfirm("注：您确定要对编号为<br />【" + th + "】<br />的零件进行【" + typeName + "】计算吗？", function (r) {
            if (r) {
                $.submitForm({
                    url: "/BOM/Product/SubmitMultiQueryCalculate",
                    param: { id: id, th: th, type: type },
                    async: false,
                    loading: "正在进行计算...",
                    success: function () {
                        flag = true;
                    }
                })
                window.setInterval(resetParent, 1000);
              }
        });
    }
    function resetParent() {
        //alert(flag);
        if (flag) {
            parent.resetPage();
        }
    }
    function btn_cancel() {
        parent.$.detailClose();
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc; " class="line-table input-width-185">
            <div class="btn-group dialog-title">
                多级查询计算
            </div>
            <div class="btn-group" style="margin-right:20px;">
                <input id="radio11" class="category" name="category" type="radio" value="Z" checked="checked" /><label for="radio11" class="suffix">展开</label><br />
                <input id="radio12" class="category" name="category" type="radio" value="H" /><label for="radio12" class="suffix">回归</label> &nbsp;&nbsp;&nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                零部件号<br /><input id="txt_keyword" name="txt_keyword" type="text" class="form-control required" /> &nbsp;&nbsp;&nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 查询</a> &nbsp;&nbsp;&nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="" class="btn btn-primary center-block" onclick="btn_cancel()"><span class="glyphicon glyphicon-download"></span> 返回</a>
            </div>
        </div>
    </form>
    <div style="padding:0 2px;">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>

